package cn.javass.dp.abstractfactory.example4;

import sun.applet.Main;

public class ComputerEngineer {

    private CPUApi cpu = null;

    private MainboradApi mainborad = null;

    private MemoryApi memory = null;

    //装机
    public void makeComputer(AbstractFactory schema) {
        //1准备好装机的组件
        prepareHardwares(schema);

        //2组装机器
        //3测试机器
        //4交付客户
    }

    private void prepareHardwares(AbstractFactory schema) {
        cpu = (CPUApi)schema.createProduct(1);
        mainborad = (MainboradApi) schema.createProduct(2);
        memory = (MemoryApi)schema.createProduct(3);

        cpu.calculate();
        mainborad.installCPU();
        if (memory != null) {
            memory.cacheData();
        }
    }

}
